class SourceLocation < Struct.new(:project, :relative_path, :line_no)
  def ==(another)
    in_same_file?(another) && line_no == another.line_no
  end
  
  def <=>(another)
    in_same_file?(another) ? line_no <=> another.line_no : relative_path <=> another.relative_path 
  end
  
  def in_same_file?(another_location)
    project == another_location.project && relative_path == another_location.relative_path
  end
  
  def absolute_path
    project.expand_path(relative_path)
  end
  
  def open
    TextMate.go_to({:file => absolute_path, :line => line_no})
  end
  
  def to_s
    "#{relative_path} :#{line_no}"
  end
end